function is_mobileQQ() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/\sQQ/i) == " qq" && /iphone/i.test(ua) == false) {
        return true;
    } else {
        return false;
    }
}
function is_weixin() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
    } else {
        return false;
    }
}
function is_own_app(){
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/\sbaoxb/i) == " duobao" && /iphone/i.test(ua) == false) {
        return true;
    } else {
        return false;
    }
}
$(function(){
    $(".J_backToPrev").click(function(){
         window.history.back(-1);
    });
    //检测请求来源
    function initDownload(){
        if(is_own_app()){
            $(".wfqDwVOe").addClass("hide");
        }else{
            $(".wfqDwVOe").removeClass("hide");
            $(".u-download-text").click(function(){
                window.location.href="/download";
            });
            $(".u-download-close").click(function(){
                $(".wfqDwVOe").addClass("hide");
            });
        }
    }
    $(".bDialog").click(function(){
         var dataUrl=$(this).attr("data-addressurl");
         var title=$(this).attr("data-title");
         $.ajax({
            url: dataUrl,
            type: "GET",
            dataType: "text",
            cache: false,
            success: function(data) {
                $.dialog({title:title,content:data})
            },
            error:function(){

            }
         });


    });

    //initDownload();
});

/** 插件编写*/
(function($) {

    $.dialog = function(options) {
        var settings = {
            title:"",
            content:""
        };
        $.extend(settings, options);
        if (settings.content == null) {
            return false;
        }
        var $dialog = $('<div class="modal ui-modal-panelbottom"></div>');

        var $header=$('<div class="modal-header"></div>');
        var $dialogClose = $('<a href="javascript:void(0)" class="closeBtn" mars_sead="checkout_close_button"><span>×</span></a>').appendTo($header);
        var $dialogTitle=$('<h3>'+settings.title+'</h3>').appendTo($header);
        var $dialogContent;
        var $dialogOverlay;
        $header.appendTo($dialog);
        $dialogContent = $('<div class="modal-body modal-body-noBotton">').appendTo($dialog);
        $dialog.appendTo("body");
        if (settings.title != null) {
            $dialogTitle.text(settings.title);
        }
        $dialogContent.html(settings.content);
         $dialog.css({"width": "100%", "visibility": "visible","display": "block","left": "0px","bottom": "0px","opacity": 1});
        dialogShow();
        if ($dialogClose != null) {
            $dialogClose.click(function() {
                dialogClose();
                return false;
            });
        }
        function dialogShow() {
            if (settings.onShow && typeof settings.onShow == "function") {
                if (settings.onShow($dialog) != false) {
                    $dialog.show();
                }
            } else {
                $dialog.show();
            }
        }
        function dialogClose() {
            if (settings.onClose && typeof settings.onClose == "function") {
                if (settings.onClose($dialog) != false) {
                    $dialog.remove();
                }
            } else {
                $dialog.remove();
            }
        }
        return $dialog;
    };

})(jQuery);
